package easy

func HasAlternatingBits(n int) bool {
	prev := n % 2
	n /= 2
	for n != 0 {
		cur := n % 2
		if cur == prev {
			return false
		}
		prev = cur
		n /= 2
	}
	return true
}
